import { getBaseURL, get, post, deletes } from "./request";
const HttpManager = {
    // 获取图片信息   后台数据包含/所以此处直接使用${url}而不是/${url}
    attachImageUrl: (url) => url ? `${getBaseURL()}${url}` : "https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png",

    //获取所有的海报
    getBannerList: () => get("banner/getAllBanner"),

    // =======================> 歌单 API 完成
    // 获取全部歌单
    getSongList: () => get("songlist/list"),
    // 返回标题包含文字的歌单
    getSongListOfLikeTitle: (keywords) => get(`songList/likeTitle/detail?title=${keywords}`),


    // =======================> 歌手 API  完成
    // 返回所有歌手
    getAllSinger: () => get("singer/list"),
    
    
    // =======================> 歌曲 API
    // 返回指定歌手名的歌曲
    getSongOfSingerName: (keywords) => get(`song/singerName/detail?name=${keywords}`),
    // 验证用户名和密码
    signIn: (user) => post("user/validate",user),

    // 注册
    signUp: (user) => post("user/add",user),
    // 返回指定歌曲ID的歌曲
    getSongOfId: (id) => get(`song/detail?id=${id}`),

    // 返回指定ID的用户
    getUserOfId: (id) => get(`user/detail?id=${id}`),

    // 返回的指定用户ID的收藏列表
    getCollectionOfUser: (userId) => get(`collection/detail?userId=${userId}`),

    // 更新用户头像
    uploadUrl: (userId) => `${getBaseURL()}/user/avatar/update?id=${userId}`,

     // 更新用户信息
     updateUserMsg: ({ id, username, sex, phoneNum, email, birth, introduction, location }) => post(`user/update`, { id, username, sex, phoneNum, email, birth, introduction, location }),
     // 删除用户
     deleteUser: (id) => get(`user/delete?id=${id}`),
     // 更新用户密码
     updateUserPassword: ({ id, username, oldPassword, password }) => post(`user/updatePassword`, { id, username, oldPassword, password }),
}
export { HttpManager };